using Godot;
using System;
using MonsterDiKe.common;

namespace MonsterDiKe.player.script;

public partial class StateIdle : BaseState
{

    private StateWalk _stateWalk;

    public override void _Ready()
    {
        // 获取行走状态机
        _stateWalk = GetParent().GetNode<Node>("Walk") as StateWalk;
    }

    public override void Init()
    {
        base.Init();
    }

    public override void Enter()
    {
        // 入场播放闲置动画
        GlobalInitializationNode.Player.UpdateAnimation(PlayerAnimationPrefixNameConst.Idle);
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override BaseState Process(double delta)
    {
        Player player = GlobalInitializationNode.Player;
        // 如果当前角色存在速度则返回行走状态机
        if (!player.Direction.Equals(Vector2.Zero)) return _stateWalk;
        player.Velocity = Vector2.Zero;
        return null;
    }

    public override BaseState PhysicsProcess(double delta)
    {
        return base.PhysicsProcess(delta);
    }

    public override BaseState HandleInput(InputEvent @event)
    {
        return base.HandleInput(@event);
    }
}
